//
//  ForgetPasswordTwoViewController.m
//  PlayerWorld
//
//  Created by 1 on 16/5/16.
//  Copyright © 2016年 刘成. All rights reserved.
//
#define UISCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width
#define UISCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#import "ForgetPasswordTwoViewController.h"
#import "LZFoldButton.h"
#import "ForgetPasswordThreeViewController.h"
@interface ForgetPasswordTwoViewController ()<LZFoldButtonDelegate,UITextFieldDelegate>
{
    LZFoldButton *lz;
}


@end

@implementation ForgetPasswordTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
    self.title = @"找回密码";
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    // 状态栏(statusbar)
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    
    // 导航栏（navigationbar）
    CGRect rectNav = self.navigationController.navigationBar.frame;
    
    UILabel *securityLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, rectStatus.size.height+rectNav.size.height+20, UISCREEN_WIDTH, 40)];
    securityLabel.text = @"      问题";
    securityLabel.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:securityLabel];
    
    NSArray *arr = @[@"你母亲的名字                      ",@"你小学班主任的名字                   ",@"你发小的名字                       "];
    
    lz = [[LZFoldButton alloc]initWithFrame:CGRectMake(70, CGRectGetMinY(securityLabel.frame)+5, UISCREEN_WIDTH-70, 30) dataArray:arr];
    
    lz.lzDelegate = self;
    lz.backgroundColor = [UIColor clearColor];
    lz.lzFontSize = 12;
    lz.lzHeight = 130;
    lz.lzButtonType = 1;
    
    [lz LZSetTitle:@"请选择问题                        " forState:UIControlStateNormal];
    [lz LZSetImage:[UIImage imageNamed:@"icon_select_arrow"] forState:UIControlStateNormal];
    [lz LZSetImage:[UIImage imageNamed:@"icon_select_arrow"] forState:UIControlStateSelected];
    [lz LZSetTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.view addSubview:lz];
    
    UILabel *securityLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(securityLabel.frame)+1, UISCREEN_WIDTH, 40)];
    securityLabel2.text = @"      答案";
    securityLabel2.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:securityLabel2];
    
    UITextField *securityTextField = [[UITextField alloc]initWithFrame:CGRectMake(70, CGRectGetMinY(securityLabel2.frame)+5, UISCREEN_WIDTH-70, 30)];
    securityTextField.returnKeyType = UIReturnKeyDone;  //返回按钮的样式
    securityTextField.clearButtonMode = YES; //清除模式开启
    securityTextField.secureTextEntry = YES; //密码输入框
    //tf.keyboardType = UIKeyboardTypeNumberPad; //键盘类型
    //协议执行者交给textField自己self
    securityTextField.delegate = self;
    [self.view addSubview:securityTextField];
    
    
    UILabel *securityLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(securityLabel2.frame)+1, UISCREEN_WIDTH, 40)];
    securityLabel3.text = @"        请正确回答密保问题以找回密码";
    securityLabel3.textColor = [UIColor grayColor];
    securityLabel3.backgroundColor = [UIColor clearColor];
    securityLabel3.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:securityLabel3];
    
    UIButton *securityButton = [[UIButton alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(securityLabel3.frame)+1, UISCREEN_WIDTH-20-20, 40)];
    [securityButton addTarget:self action:@selector(securityButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [securityButton setTitle:@"下一步" forState:UIControlStateNormal];
    [securityButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    securityButton.backgroundColor = [UIColor colorWithRed:46/255.0f green:168/255.0f blue:289/255.0f alpha:1];
    [self.view addSubview:securityButton];
}


- (void)securityButtonAction:(UIButton *)sender {
    
    ForgetPasswordThreeViewController *fPTVC= [[ForgetPasswordThreeViewController alloc] init];
    [self.navigationController pushViewController:fPTVC animated:YES];
}

//UITextField控件协议方法：当点击返回按钮时方法执行
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}

-(void)LZFoldButton:(LZFoldButton*)foldButton didSelectObject:(id)obj {
    NSLog(@"%@",obj);
    
}


@end
